﻿<?php

class Application_Form_Article extends Application_Form_InlineForm {

    public function init() {
		
		$this->setAttrib('id', 'formarticle');
		
		$idarticle = new Zend_Form_Element_Hidden('idarticle',array(
		 'decorators' => $this->getElementDecoratorHidden()
		));
	
		$actionarticle = new Zend_Form_Element_Hidden('actionarticle',array(
		 'decorators' => $this->getElementDecoratorHidden()
		));
		
		$categoriearticle = new Zend_Form_Element_Select('categoriearticle', array(
                    'label' => 'Type :',
                    'required' => true,
                    'validators' => array('NotEmpty'),
                    'decorators' => $this->getElementDecorators()
                ));
				
			$categories = new Application_Model_Categorie();
			$categories = $categories->fetchAlldata();
			$i=0;
			foreach($categories as $categorie)
			{
				$categoriearticle->addMultiOption($categorie['CATEGORIE_ID'],$categorie['CATEGORIE_LIBELLE']);
				$i=$i+1;
			}	   
			
        $nomarticle = new Zend_Form_Element_Text('nomarticle', array(
                    'label' => 'Nom :',
                    'required' => true,
                    'filters' => array('StringTrim'),
                    'validators' => array(
                        array('NotEmpty', true),
						array('StringLength', true, array('max'=>50))
                    ),
                    'decorators' => $this->getElementDecorators()
                ));
				
		$descriptionarticle = new Zend_Form_Element_Textarea('descriptionarticle', array(
                    'label' => 'Description :',
                    'required' => true,
                    'filters' => array('StringTrim'),
                    'validators' => array(
                        array('NotEmpty', true),
						array('StringLength', true, array('max'=>500))
                    ),
                    'decorators' => $this->getElementDecorators()
                ));
		$descriptionarticle->setAttrib('ROWS', '4');
				
		$prixarticle = new Zend_Form_Element_Text('prixarticle', array(
                    'label' => 'Prix :',
                    'required' => true,
                    'filters' => array('StringTrim'),
                    'decorators' => $this->getElementDecorators()
				));	
				
		$PrixValidator = new Validator_Prix();
		$prixarticle->addValidator($PrixValidator, true);
		
		$couleurarticle = new Zend_Form_Element_Text('couleurarticle', array(
				'label' => 'Couleur :',
				'required' => true,
				'filters' => array('StringTrim'),
				'validators' => array(
						array('NotEmpty', true),
						array('StringLength', true, array('max'=>50))
				),
				'decorators' => $this->getElementDecorators()
		));
		
		$CouleurValidator = new Validator_Couleur();
		$couleurarticle->addValidator($CouleurValidator, true);
		
		$photo = new Zend_Form_Element_Hidden('$photo',array(
		 'decorators' => $this->getElementDecoratorHidden()
		));
		
		$extension = new Zend_Form_Element_Hidden('extension',array(
				'decorators' => $this->getElementDecoratorHidden()
		));
		
		$uploadphoto =  new Zend_Form_Element_Text('$uploadphoto', array(
                    'required' => true,
                    'filters' => array('StringTrim'),
                    'validators' => array(
                        array('NotEmpty', true),
						array('StringLength', true, array('max'=>50))
                    ),
                    'decorators' => $this->getElementDecorators(),
					'name' =>'file_upload'
         ));

        $this->addElements(array($idarticle,$actionarticle,$categoriearticle, $nomarticle, $descriptionarticle, $prixarticle, $uploadphoto, $extension, $photo, $couleurarticle));
    }
}